package com.kexio.config.enums;

/**
 * 配置类型枚举
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
public enum ConfigType {
    
    /**
     * 系统配置
     */
    SYSTEM("SYSTEM", "系统配置"),
    
    /**
     * 业务配置
     */
    BUSINESS("BUSINESS", "业务配置"),
    
    /**
     * 界面配置
     */
    UI("UI", "界面配置"),
    
    /**
     * 安全配置
     */
    SECURITY("SECURITY", "安全配置"),
    
    /**
     * 性能配置
     */
    PERFORMANCE("PERFORMANCE", "性能配置"),
    
    /**
     * 集成配置
     */
    INTEGRATION("INTEGRATION", "集成配置"),
    
    /**
     * 用户配置
     */
    USER("USER", "用户配置"),
    
    /**
     * 缓存配置
     */
    CACHE("CACHE", "缓存配置"),
    
    /**
     * 数据库配置
     */
    DATABASE("DATABASE", "数据库配置"),
    
    /**
     * 消息配置
     */
    MESSAGE("MESSAGE", "消息配置");
    
    private final String code;
    private final String description;
    
    ConfigType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static ConfigType fromCode(String code) {
        for (ConfigType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown config type code: " + code);
    }
    
    /**
     * 是否为系统级配置
     */
    public boolean isSystemLevel() {
        return this == SYSTEM || this == SECURITY || this == PERFORMANCE || this == DATABASE;
    }
    
    /**
     * 是否为用户级配置
     */
    public boolean isUserLevel() {
        return this == USER || this == UI;
    }
}
